package com.tangding.hprose.api.server.command.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.tangding.common.data.Constants;
import com.tangding.common.exception.GException;
import com.tangding.hprose.api.server.command.Command;
import com.tangding.hprose.api.server.command.Response;

/**
 * @description 暂时模拟，让客户端不报错
 *
 * @author Ranger
 * @version 2017年12月19日_下午6:17:34
 *
 */
@Component
public class Summary implements Command {

	@Override
	public Response exe(Object... params) throws GException {
		Map<String, Object> result = new HashMap<>();
		result.put("todayAndYesterdayRegistChartsData", todayAndYesterdayRegistChartsData());
		result.put("commonDatas", commonData());
		return doResponseSucc(result);
	}

	public List<Map<String, Object>> commonData(){
		List<Map<String, Object>> list = new ArrayList<>();
		Map<String, Object> map = new HashMap<>();
		map.put("key", "todayAddUser");
		map.put("info", "今日新增用户");
		map.put("value", 152203);
		list.add(map);
		
		map = new HashMap<>();
		map.put("key", "yestodayAddUser");
		map.put("info", "昨日新增注册");
		map.put("value", 150000);
		list.add(map);
		
		map = new HashMap<>();
		map.put("key", "totalUser");
		map.put("info", "平台总用户");
		map.put("value", 15001100);
		list.add(map);
		
		map = new HashMap<>();
		map.put("key", "totalRegist");
		map.put("info", "平台总注册");
		map.put("value", 15100000);
		list.add(map);
		
		map = new HashMap<>();
		map.put("key", "onlineNum");
		map.put("info", "当前在线用户");
		map.put("value", 200);
		list.add(map);
		
		map = new HashMap<>();
		map.put("key", "rechargeToday");
		map.put("info", "今日充值");
		map.put("value", 150000);
		list.add(map);
		
		map = new HashMap<>();
		map.put("key", "rechargeYestoday");
		map.put("info", "昨日充值");
		map.put("value", 180000);
		list.add(map);
		
		map = new HashMap<>();
		map.put("key", "rechargeMonth");
		map.put("info", "本月总充值");
		map.put("value", 150000);
		list.add(map);
		
		map = new HashMap<>();
		map.put("key", "totalScore");
		map.put("info", "玩家下分总数");
		map.put("value", 100050000);
		list.add(map);
		return list;
	}
	
	public List<Map<String, Object>> todayAndYesterdayRegistChartsData(){
		List<Map<String, Object>> list = new ArrayList<>();
		for (int i = 0; i < 24; i++) {
			Map<String, Object> item = new HashMap<>();
			item.put("time", (i < 10 ? ("0" + i) : i) + ":00");
			item.put("today", Constants.random.nextInt(100));
			item.put("yesterday", Constants.random.nextInt(100));
			list.add(item);
		}
		return list;
	}
}
